package com.tbit.uqbike.webmanager.controller;

import com.tbit.uqbike.annos.OperateLog;
import com.tbit.common.constant.MethodEnum;
import com.tbit.common.constant.ModuleEnum;
import com.tbit.uqbike.object.pojo.HolderAccountBound;
import com.tbit.uqbike.object.view.JsonResult;
import com.tbit.uqbike.service.business.HolderAccountBoundService;
import com.tbit.uqbike.webmanager.util.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @Author: chen
 * @Description: 股东区域绑定
 * @Date: 创建于 16:12 2020/8/13
 */
@RestController
@RequestMapping("/holder")
public class HolderAccountBoundController {
    @Autowired
    private HolderAccountBoundService holderAccountBoundService;

    /**
     * 获取股东账号绑定角色信息
     *
     * @param accountUserId
     * @return
     */
    @RequestMapping("/getByAccountUserId")
    public JsonResult getByAccountUserId(@NotNull(message = "ver.accountId.notNull") Integer accountUserId) {

        List<HolderAccountBound> list = holderAccountBoundService.getByAccountUserId(accountUserId);
        return JsonResult.ok(list);
    }

    /**
     * 新增
     *
     * @param holderAccountBound
     * @return
     */
    @RequestMapping("/add")
    @OperateLog(module = ModuleEnum.MAINACCOUNTUSER, methods = MethodEnum.ACCOUNT_HOLDER_EDIT)
    public JsonResult add(HolderAccountBound holderAccountBound) {
        Assert.notNull(holderAccountBound.getAccountUserId(), "ver.accountUserId.notNull");
        Assert.notNull(holderAccountBound.getAccountId(), "ver.adAccountId.notNull");
        holderAccountBoundService.insert(holderAccountBound);
        return JsonResult.ok();
    }

    /**
     * 删除
     *
     * @param holderAccountBound
     * @return
     */
    @RequestMapping("/del")
    @OperateLog(module = ModuleEnum.MAINACCOUNTUSER, methods = MethodEnum.ACCOUNT_HOLDER_DEL)
    public JsonResult del(HolderAccountBound holderAccountBound) {
        Assert.notNull(holderAccountBound.getAccountUserId(), "ver.accountUserId.notNull");
        Assert.notNull(holderAccountBound.getAccountId(), "ver.adAccountId.notNull");
        holderAccountBoundService.del(holderAccountBound);
        return JsonResult.ok();
    }

}
